from time import time


def getTame(a):  
    start = time()
    i = 0
    c = 1
    while c == 1:
        c = 0
        for j in range(len(a) - i - 1):
            if a[j] > a[j + 1]:
                c = 1
                a[j], a[j + 1] = a[j + 1], a[j]

    end = time()
    return end - start

files =['m1_sorted.txt','m2_reverse.txt','m3_shuffle.txt']
for index in range(len(files)):
    filename = files[index]
    f = open(filename)
    m_sorted = []
    for i in f:
        m_sorted.append(i.strip('\n')) 
    f.close()
    print('m'+str(index+1)+'_sorted', int(getTame(m_sorted)), )  
